IF EXISTS ( SELECT  *
            FROM    dbo.sysobjects
            WHERE   id = OBJECT_ID(N'[CGO_EventCharityDelete]')
                    AND OBJECTPROPERTY(id, N'IsProcedure') = 1 ) 
  DROP PROCEDURE CGO_EventCharityDelete
GO

SET QUOTED_IDENTIFIER ON
SET ANSI_NULLS ON
GO


CREATE PROCEDURE dbo.CGO_EventCharityDelete
  @PortalID INT,
  @EventID INT ,
  @CharityID INT
AS
  IF @CharityID IS NULL OR @CharityID<0
  BEGIN
  	SET @CharityID = 0
  END 
  
  DELETE  FROM dbo.CGO_EventCharity
  WHERE   PortalID = @PortalID
          AND EventID = @EventID
          AND ( @CharityID = 0
                OR CharityID = @CharityID
              )
GO
